<%--
  Created by IntelliJ IDEA.
  User: 杨娇
  Date: 2025/6/23
  Time: 10:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绿能充 - 充电桩管理</title>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        :root {
            --primary-color: #00a896;
            --secondary-color: #02c39a;
            --dark-color: #05668d;
            --light-color: #f0f3bd;
            --accent-color: #028090;
            --text-dark: #333;
            --text-light: #f8f9fa;
            --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Noto Sans SC', sans-serif;
            color: var(--text-dark);
            background-color: #f9f9f9;
            min-height: 100vh;
            display: flex;
        }

        /* 侧边栏样式 - 与主页面完全一致 */
        .sidebar {
            width: 250px;
            background: linear-gradient(135deg, var(--dark-color) 0%, var(--primary-color) 100%);
            color: white;
            padding: 20px 0;
            height: 100vh;
            position: fixed;
            box-shadow: var(--shadow);
            z-index: 100;
        }

        .sidebar-header {
            padding: 0 20px 20px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            margin-bottom: 20px;
        }

        .sidebar-header .logo {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }

        .sidebar-header .logo-icon {
            width: 40px;
            height: 40px;
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 18px;
            color: var(--light-color);
        }

        .sidebar-header h3 {
            font-size: 1.2rem;
            font-weight: 500;
            margin: 0;
        }

        .sidebar-header p {
            font-size: 0.8rem;
            opacity: 0.8;
            margin: 0;
        }

        .nav-menu {
            list-style: none;
            padding: 0 15px;
        }

        .nav-item {
            margin-bottom: 5px;
        }

        .nav-link {
            display: flex;
            align-items: center;
            padding: 12px 15px;
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
            border-radius: 8px;
            transition: var(--transition);
        }

        .nav-link:hover, .nav-link.active {
            background-color: rgba(255, 255, 255, 0.1);
            color: white;
        }

        .nav-link i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
            font-size: 16px;
        }

        .user-profile {
            position: absolute;
            bottom: 20px;
            left: 0;
            width: 100%;
            padding: 0 20px;
        }

        .user-info {
            display: flex;
            align-items: center;
            padding: 10px;
            background-color: rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            cursor: pointer;
            transition: var(--transition);
        }

        .user-info:hover {
            background-color: rgba(255, 255, 255, 0.2);
        }

        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 14px;
        }

        .user-name {
            font-size: 0.9rem;
            font-weight: 500;
            margin-bottom: 2px;
        }

        .user-role {
            font-size: 0.7rem;
            opacity: 0.8;
        }

        /* 主内容区样式 */
        .main-content {
            flex: 1;
            margin-left: 250px;
            padding: 30px;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }

        .page-title h1 {
            font-size: 1.8rem;
            font-weight: 600;
            color: var(--dark-color);
            margin-bottom: 5px;
        }

        .page-title p {
            color: #777;
            font-size: 0.9rem;
            margin: 0;
        }

        .header-actions {
            display: flex;
            gap: 10px;
        }

        .btn {
            padding: 8px 16px;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: 500;
            border: none;
            cursor: pointer;
            transition: var(--transition);
            display: flex;
            align-items: center;
        }

        .btn i {
            margin-right: 6px;
        }

        .btn-primary {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            color: white;
            box-shadow: 0 4px 15px rgba(0, 168, 150, 0.3);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(0, 168, 150, 0.4);
        }

        .btn-outline {
            background: transparent;
            border: 1px solid #ddd;
            color: #555;
        }

        .btn-outline:hover {
            background-color: #f5f5f5;
        }

        .btn-danger {
            background: #ffebee;
            color: #f44336;
            border: 1px solid #ffcdd2;
        }

        .btn-danger:hover {
            background: #ffcdd2;
        }

        /* 搜索和筛选区域 */
        .filter-container {
            background-color: white;
            border-radius: 12px;
            padding: 20px;
            box-shadow: var(--shadow);
            margin-bottom: 20px;
        }

        .filter-row {
            display: flex;
            gap: 15px;
            margin-bottom: 15px;
        }

        .filter-group {
            flex: 1;
        }

        .filter-group label {
            display: block;
            margin-bottom: 8px;
            font-size: 0.9rem;
            color: #555;
            font-weight: 500;
        }

        .filter-control {
            width: 100%;
            padding: 10px 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-family: inherit;
            font-size: 0.9rem;
            transition: var(--transition);
        }

        .filter-control:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(0, 168, 150, 0.2);
        }

        /* 表格样式 */
        .card {
            background-color: white;
            border-radius: 12px;
            box-shadow: var(--shadow);
            padding: 20px;
            margin-bottom: 20px;
            transition: var(--transition);
            position: relative;
            overflow: hidden;
        }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }

        .card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid #eee;
        }

        .card-header h3 {
            font-size: 1.2rem;
            font-weight: 600;
            margin: 0;
            color: var(--dark-color);
        }

        .table-responsive {
            overflow-x: auto;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }

        th {
            font-weight: 500;
            color: #555;
            font-size: 0.9rem;
        }

        tr:hover {
            background-color: #f9f9f9;
        }

        .badge {
            display: inline-block;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.75rem;
            font-weight: 500;
        }

        .badge-success {
            background-color: #e8f5e9;
            color: #4caf50;
        }

        .badge-warning {
            background-color: #fff8e1;
            color: #ff9800;
        }

        .badge-danger {
            background-color: #ffebee;
            color: #f44336;
        }

        .badge-info {
            background-color: #e3f2fd;
            color: #2196f3;
        }

        .badge-secondary {
            background-color: #e0e0e0;
            color: #616161;
        }

        /* 分页样式 */
        .pagination {
            display: flex;
            justify-content: center;
            margin-top: 20px;
        }

        .page-item {
            margin: 0 5px;
        }

        .page-link {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            border-radius: 8px;
            background-color: white;
            border: 1px solid #ddd;
            color: #555;
            text-decoration: none;
            transition: var(--transition);
        }

        .page-link:hover {
            background-color: #f5f5f5;
        }

        .page-item.active .page-link {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            color: white;
            border-color: var(--primary-color);
        }

        /* 模态框样式 */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            align-items: center;
            justify-content: center;
        }

        .modal-content {
            background-color: white;
            border-radius: 12px;
            width: 100%;
            max-width: 600px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            animation: modalFadeIn 0.3s ease-out;
        }

        @keyframes modalFadeIn {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .modal-header {
            padding: 20px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-header h3 {
            margin: 0;
            color: var(--dark-color);
        }

        .modal-close {
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            color: #777;
        }

        .modal-body {
            padding: 20px;
        }

        .modal-footer {
            padding: 15px 20px;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: #555;
        }

        .form-control {
            width: 100%;
            padding: 10px 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-family: inherit;
            font-size: 0.9rem;
            transition: var(--transition);
        }

        .form-control:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(0, 168, 150, 0.2);
        }

        /* 响应式设计 */
        @media (max-width: 992px) {
            .sidebar {
                width: 70px;
                overflow: hidden;
            }

            .sidebar-header h3,
            .sidebar-header p,
            .nav-link span,
            .user-name,
            .user-role {
                display: none;
            }

            .sidebar-header {
                padding: 15px 10px;
            }

            .nav-link {
                justify-content: center;
                padding: 12px 0;
            }

            .nav-link i {
                margin-right: 0;
                font-size: 18px;
            }

            .main-content {
                margin-left: 70px;
            }
        }

        @media (max-width: 768px) {
            .filter-row {
                flex-direction: column;
            }
            .header {
                flex-direction: column;
                align-items: flex-start;
                gap: 15px;
            }
        }

        @media (max-width: 576px) {
            .main-content {
                padding: 20px 15px;
            }
        }
    </style>
</head>
<body>
<!-- 侧边导航栏 - 与主页面完全一致 -->
<div class="sidebar">
    <div class="sidebar-header">
        <div class="logo">
            <div class="logo-icon">
                <i class="fas fa-charging-station"></i>
            </div>
            <div>
                <h3>绿能充</h3>
                <p>管理员面板</p>
            </div>
        </div>
    </div>

    <ul class="nav-menu">
        <li class="nav-item">
            <a href="/admin/dashboard" class="nav-link">
                <i class="fas fa-tachometer-alt"></i>
                <span>仪表盘</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/user/list" class="nav-link">
                <i class="fas fa-users"></i>
                <span>用户管理</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/pile/list" class="nav-link active">
                <i class="fas fa-charging-station"></i>
                <span>充电桩管理</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/announcement/list" class="nav-link">
                <i class="fas fa-bullhorn"></i>
                <span>公告管理</span>
                <span class="badge">2</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/report/list" class="nav-link">
                <i class="fas fa-list-alt"></i>
                <span>充电记录</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/fault/list" class="nav-link">
                <i class="fas fa-exclamation-triangle"></i>
                <span>故障报告</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/settings" class="nav-link">
                <i class="fas fa-cog"></i>
                <span>系统设置</span>
            </a>
        </li>
    </ul>

    <div class="user-profile">
        <div class="user-info">
            <div class="user-avatar">
                <i class="fas fa-user"></i>
            </div>
            <div>
                <div class="user-name">管理员</div>
                <div class="user-role">超级管理员</div>
            </div>
        </div>
    </div>
</div>

<!-- 主内容区 -->
<div class="main-content">
    <div class="header">
        <div class="page-title">
            <h1>充电桩管理</h1>
            <p>管理所有充电桩设备信息</p>
        </div>
        <div class="header-actions">
            <button class="btn btn-outline">
                <i class="fas fa-download"></i> 导出
            </button>
            <button class="btn btn-primary">
                <a href="${pageContext.request.contextPath}/admin/pile/add">
                    <i class="fas fa-plus"></i> 添加充电桩
                </a>
            </button>
        </div>
    </div>

    <!-- 筛选区域 -->
    <div class="filter-container">
        <div class="filter-row">
            <div class="filter-group">
                <label for="search">搜索</label>
                <input type="text" id="search" class="filter-control" placeholder="充电桩编号、位置...">
            </div>
            <div class="filter-group">
                <label for="status">状态</label>
                <select id="status" class="filter-control">
                    <option value="">全部状态</option>
                    <option value="available">可用</option>
                    <option value="charging">充电中</option>
                    <option value="fault">故障</option>
                    <option value="maintenance">维护中</option>
                </select>
            </div>
        </div>
        <div class="filter-row">
            <div class="filter-group">
                <label for="type">类型</label>
                <select id="type" class="filter-control">
                    <option value="">全部类型</option>
                    <option value="fast">快充</option>
                    <option value="slow">慢充</option>
                </select>
            </div>
            <div class="filter-group">
                <label for="location">位置</label>
                <select id="location" class="filter-control">
                    <option value="">全部位置</option>
                    <option value="north">北区</option>
                    <option value="south">南区</option>
                    <option value="east">东区</option>
                    <option value="west">西区</option>
                </select>
            </div>
        </div>
        <button class="btn btn-primary">
            <i class="fas fa-filter"></i> 筛选
        </button>
        <button class="btn btn-outline">
            <i class="fas fa-sync-alt"></i> 重置
        </button>
    </div>

    <!-- 充电桩列表 -->
    <div class="card">
        <div class="card-header">
            <h3>充电桩列表</h3>
            <div class="card-actions">
                <span class="text-muted">共 <strong>${totalPiles}</strong> 个充电桩</span>
            </div>
        </div>
        <div class="table-responsive">
            <table>
                <thead>
                <tr>
                    <th>充电桩编号</th>
                    <th>名称</th>
                    <th>位置</th>
                    <th>类型</th>
                    <th>功率(kW)</th>
                    <th>状态</th>
                    <th>价格(元/度)</th>
                    <th>运营商</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${pileList}" var="pile">
                    <tr>
                        <td>${pile.code}</td>
                        <td>${pile.name}</td>
                        <td>${pile.location}</td>
                        <td>
                            <c:choose>
                                <c:when test="${pile.type == 'DC'}">
                                    <span class="badge badge-info">直流快充</span>
                                </c:when>
                                <c:otherwise>
                                    <span class="badge badge-secondary">交流慢充</span>
                                </c:otherwise>
                            </c:choose>
                        </td>
                        <td>${pile.power}</td>
                        <td>
                            <c:choose>
                                <c:when test="${pile.status == 'AVAILABLE'}">
                                    <span class="badge badge-success">可用</span>
                                </c:when>
                                <c:when test="${pile.status == 'CHARGING'}">
                                    <span class="badge badge-warning">充电中</span>
                                </c:when>
                                <c:when test="${pile.status == 'FAULT'}">
                                    <span class="badge badge-danger">故障</span>
                                </c:when>
                                <c:when test="${pile.status == 'MAINTENANCE'}">
                                    <span class="badge badge-secondary">维护中</span>
                                </c:when>
                            </c:choose>
                        </td>
                        <td>${pile.price}</td>
                        <td>${pile.operator}</td>
                        <td>
                            <button class="btn btn-outline btn-sm">
                                <a href="${pageContext.request.contextPath}/admin/pile/edit/${pile.id}">
                                    <i class="fas fa-edit"></i> 编辑
                                </a>
                            </button>
                            <button class="btn btn-danger btn-sm">
                                <a href="${pageContext.request.contextPath}/admin/pile/delete/${pile.id}"
                                   onclick="return confirm('确定要删除用户 ${pile.name} 吗？此操作不可恢复！')">
                                    <i class="fas fa-trash"></i> 删除
                                </a>
                            </button>
                            <button class="btn btn-info btn-sm">
                                <a href="${pageContext.request.contextPath}/admin/pile/detail/${pile.id}">
                                    <i class="fas fa-info-circle"></i> 详情
                                </a>
                            </button>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>

        <!-- 分页 -->
        <div class="pagination">
            <c:if test="${currentPage > 1}">
                <a href="?page=${currentPage-1}" class="page-item">
                    <span class="page-link"><i class="fas fa-chevron-left"></i></span>
                </a>
            </c:if>

            <c:forEach begin="1" end="${totalPages}" var="i">
                <a href="?page=${i}" class="page-item ${currentPage == i ? 'active' : ''}">
                    <span class="page-link">${i}</span>
                </a>
            </c:forEach>

            <c:if test="${currentPage < totalPages}">
                <a href="?page=${currentPage+1}" class="page-item">
                    <span class="page-link"><i class="fas fa-chevron-right"></i></span>
                </a>
            </c:if>
        </div>
    </div>
</div>

<script>

    // 确认删除
    function confirmDelete(pileId) {
        if (confirm('确定要删除这个充电桩吗？此操作不可恢复。')) {
            // 这里应该是提交删除请求
            window.location.href = '/admin/pile/delete?id=' + pileId;
        }
    }

    // 点击模态框外部关闭
    window.onclick = function(event) {
        if (event.target.className === 'modal') {
            event.target.style.display = 'none';
        }
    }
</script>
</body>
</html>